Conventionally, in an image forming apparatus, e.g., a printer and a facsimile machine, it is detected whether a recording medium remains in a conveying path when an error occurred during conveyance of the recording medium. There has been known, for example, an image forming apparatus that comprises a pickup device, which feeds recording media, one by one, a storage device, which stores a value obtained by adding a certain value to the stored value every time a recording medium is fed and reducing the certain value from the stored value every time print data is processed, and an output device, which outputs the value stored in the storage device as the number of recording media remaining in the image forming apparatus when an error occurred in the conveyance of the recording medium. In the image forming apparatus, the number of recording media remaining in the image forming apparatus can be obtained when an error occurred in the conveyance of the recording medium.
There has been known a sheet handling device that comprises a plurality of sensors disposed at a plurality of respective positions in a conveying path to detect passage of leading and trailing edges of a recording medium (a sheet). In the sheet handling device, when a controller cannot detect states (on/off) of the sensors disposed in a downstream part of the conveying path within a predetermined time after detecting states (on/off) of the sensors disposed in an upstream part of the conveying path, the controller determines that a paper jam has occurred and stops the operation of the sheet handling device.
In a case where the presence or absence of a remaining recording medium is determined by using a detection signal from the sensors as described above, generally, a state of a control flag is changed between on and off when a detection signal is sent from the upstream sensor or the downstream sensor. A rewritable storage stores the control flag. The controller accesses the storage device to rewrite the control flag every time the controller receives a detection signal.